import { configureStore, ThunkAction, Action } from '@reduxjs/toolkit'
// 状态管理器
import { createStore } from 'redux'
import reducer from './reducer'
// import counterReducer from '../features/counter/counterSlice';

// export const store = configureStore({
//   reducer: {
//     counter: counterReducer,
//   },
// });

const store = createStore(reducer)

export type AppDispatch = typeof store.dispatch
// ReturnType ts提供了一个：反向注入 一次性注解 store.getState 获取state状态值
export type RootState = ReturnType<typeof store.getState>

export type AppThunk<ReturnType = void> = ThunkAction<
  ReturnType,
  RootState,
  unknown,
  Action<string>
>
export { store }
